package com.hello.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hello.dto.PostLikeDTO;
import com.hello.entity.Post;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface PostMapper extends BaseMapper<Post> {

    @Select("SELECT " +
            "user.headshot_url, " +
            "user.username, " +
            "posts.text, " +
            "posts.post_time " +
            "FROM p_likes, posts, user " +
            "WHERE p_likes.liker_id = user.user_id " +
            "AND p_likes.host_id = posts.host_id " +
            "AND p_likes.post_order = posts.post_order " +
            "AND user.user_id = posts.host_id " +
            "AND posts.host_id = #{hostId}")
    List<PostLikeDTO> Select_PDI(@Param("hostId") Long hostId);

    @Select("SELECT MAX(post_order) FROM posts")
    Integer getMaxPostOrder();
}
